package com.easylinkin.linkappapi.common.config;

import org.apache.tomcat.util.http.SameSiteCookies;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * 自定义springSession配置
 * @author zhengwen
 */
//@Configuration
public class SpringSessionConfiguration {
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer serializer = new DefaultCookieSerializer();
        //serializer.setCookieName("SESSION");
        //serializer.setDomainName("localhost");
        serializer.setCookiePath("/");
        //serializer.setCookieMaxAge(3600);
        // 设置SameSite属性
        serializer.setSameSite(SameSiteCookies.NONE.getValue());
        serializer.setUseHttpOnlyCookie(true);
        //serializer.setUseSecureCookie(true);
        return serializer;
    }

}
